Image processing device and method for compressing and decompressing images

ABSTRACT

The disclosed image processing device receiving image data comprises a first encoder, a second encoder and an encoding switch. The first encoder generates first data by encoding the image data according to a predetermined method. The second encoder generates second data by encoding the image data according to an encoding pattern table. The encoding pattern table is set up in accordance with the first data. The encoding switch determines to output either the first data or the second data as an encoded result and generates a mark value for indicating the encoded result.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to image processing, and in particularrelates to devices and methods of image compression and decompressionfor synthetic images

2. Description of the Related Art

The rapid growth of digital imaging applications, including desktoppublishing, multimedia, teleconferencing, and high-definition television(HDTV) has increased the need for efficient and standardized imagecompression techniques. Without image compression, the transmission ofimages would require an unacceptable bandwidth for many applications. Asa result, methods of compressing images have been the subject ofnumerous research publications. Image compression schemes convert animage consisting of a two-dimensional array of pixels into a sequence ofbits which are transmitted over a communication link. Each pixelrepresents the intensity of the image at a particular location therein.The transmission link may be an ordinary telephone line.

Consider an image comprising a gray-scale representation of a photographat a resolution of 1000×1000 lines. Each pixel typically consists of 8bits which are used to encode 256 possible intensity levels at thecorresponding point on the photograph. Hence, without compression,transmission of the photograph requires that 8 million bits be sent overthe communication link. A typical telephone line is capable oftransmitting about 9600 bits per second; hence the picture transmissionwould require more than 10 minutes. Transmission times of this magnitudeare unacceptable.

As a result, image compression systems are needed to reduce transmissiontime. It is also apparent to those skilled in the art that imagecompression systems may also be advantageously employed in image storagesystems to reduce the amount of memory needed to store one or moreimages.

Further, there are two kinds of images, natural images and syntheticimages. In general, high frequency components only occur in luminancedomain for natural images. Contrary to natural images, high frequencycomponents occur in both of luminance and chrominance domains forsynthetic images. Due to synthetic images having more high frequencycomponents than natural images, it is more difficult to compresssynthetic images than natural images.

BRIEF SUMMARY OF INVENTION

A detailed description is given in the following embodiments withreference to the accompanying drawings.

An image processing device is disclosed. The image processing devicereceiving image data comprising a plurality of pixel values comprises afirst encoder, a second encoder and an encoding switch. The firstencoder is configured to generate first data by encoding the image dataaccording to a predetermined method. The second encoder is configured togenerate second data by encoding the image data according to an encodingpattern table. The encoding pattern table is set up in accordance withthe first data The encoding switch is configured to determine to outputeither the first data or the second data as an encoded result andgenerate a mark value for indicating the encoded result.

An image processing method is disclosed. The image processing methodreceives image data comprising a plurality of pixel values by an imageprocessing unit. An encoding pattern table comprising a plurality ofencoding indexes and encoding values stored in a first storage elementis provided. Each encoding value corresponding to one of the encodingindexes in the encoding pattern table. First data is generated byencoding the image data according to a predetermined method. Second datais generated by encoding the image data according to the encodingpattern table. Either the first data or the second data is determined tobe outputted as an encoded result according to characteristics of thefirst data and the second data by an encoding switch. First decodingdata comprising first values is obtained by decoding the first dataaccording to the predetermined method and using the first values toupdate the encoding values in the encoding pattern table when theencoded result is the first data encoded according to the predeterminedmethod. A mark value indicating the encoded result is the first dataencoded according to the predetermined method or is the second dataencoded according to the encoding pattern table is generated.

BRIEF DESCRIPTION OF DRAWINGS

The present invention can be more fully understood by reading thesubsequent detailed description and examples with references made to theaccompanying drawings, wherein:

FIG. 1 is a diagram illustrating the image processing device disclosedin the embodiment;

FIG. 2A is a diagram illustrating an exemplar of the encoding patterntable in the embodiment;

FIG. 2B is a diagram illustrating an exemplar of the decoding patterntable in the embodiment;

FIG. 3A is a diagram illustrating an exemplar of the first decoding datacomprising the first values in an embodiment;

FIG. 3B is a diagram illustrating an exemplar of the encoding patterntable updated by the first values in FIG. 3A;

FIG. 4A is a diagram illustrating an exemplar of the encoding patterntable in an embodiment;

FIG. 4B is a diagram illustrating an exemplar of the image data in anembodiment;

FIG. 4C is a diagram illustrating an exemplar of the second data encodedaccording to the encoding pattern table in FIG. 4A from the image datain FIG. 4B;

FIG. 4D is a diagram illustrating an exemplar of the coding error of thesecond data in FIG. 4C.

FIG. 5A is a diagram illustrating an exemplar of the decoding patterntable in an embodiment;

FIG. 5B is a diagram illustrating an exemplar of the second data in anembodiment;

FIG. 5C is a diagram illustrating an exemplar of the second decodingdata decoded according to decoding pattern table in FIG. 5A from thesecond data in FIG. 5B; and

FIG. 6 is a flowchart of the image processing method disclosed in anembodiment.

DETAILED DESCRIPTION OF INVENTION

The following description is of the best-contemplated mode of carryingout the invention. This description is made for the purpose ofillustrating the general principles of the invention and should not betaken in a limiting sense. The scope of the invention is best determinedby reference to the appended claims.

To efficiently compress synthetic images, an image processing device anda method for compressing and decompressing images with increasingcompression rate for synthetic images is disclosed. FIG. 1 is a diagramillustrating the image processing device disclosed in the embodiment.Image processing device 500 comprises a first encoder 110, a secondencoder 120, an encoding switch 150, a first storage element 180, afirst decoder 210, a second decoder 220, a decoding switch 250 and asecond storage element 280. An encoding pattern table 81 comprising aplurality of encoding indexes and encoding values is stored in firststorage element 180. In the encoding pattern table, each encoding valuecorresponds to one of the encoding indexes. A decoding pattern table 82comprising a plurality of decoding indexes and decoding values is storedin second storage element 280. In the decoding pattern table, eachdecoding value corresponds to one of the decoding indexes. The detailsof generating both encoding pattern table 81 and decoding pattern table82 are introduced later. Sizes of encoding pattern table 81 and decodingpattern table 82 are the same and limited depending on requirements, forexample, encoding pattern table 81 may record k+1 encoding valuesEV₀˜EV_(k) corresponding to encoding indexes 0˜k as shown in FIG. 2A,along with decoding pattern table 82 as shown in FIG. 2B. There are k+1decoding values DV₀˜DV_(k) corresponding to decoding indexes 0˜k whichmay be recorded in decoding pattern table 82.

In the beginning, all the encoding values and the decoding values arenull. First, image processing device 500 initially receives image dataIMG₀. First encoder 110 generates first data DAT₁ by encoding IMG₀according to discrete cosine transformation (DCT) method, which is apredetermined method in the embodiment. Next, encoding switch 150outputs first data DAT₁ as an encoding result and obtains first decodingdata DE₁ comprising first values v1 ₀˜v1 _(n) by decoding DAT₁ accordingto the DCT method. Then, encoding pattern table 81 with null encodingvalues is updated by first data DAT₁, first values v1 ₀˜v1 _(n) areadded to be the encoding values in encoding pattern table 81. Pleasenote that, when any two of the first values are close, only one of themis added into encoding pattern table 81.

An exemplary embodiment of using the first values to update encodingpattern table 81 is shown as follows. In the embodiment, encodingpattern table 81 may recode 8 encoding values EV₀ ˜EV₇, EV₀ ˜EV₇ arenull in the beginning. First decoding data DE₁ comprising 16 firstvalues V1 ₀˜v1 ₅ is decoded from DAT₁ according to the DCT method asshown in FIG. 3A. For v1 ₀, since all the encoding values are null,first encoder adds 58(v1 ₀) to encoding pattern table 81 to update EV₀.Next for v1 ₁, difference between 57(v1 ₁) and 58(EV₀) is 1: which isnot larger than 8, thus 57(v1 ₁) is not added to encoding pattern table81. For v1 ₂, differences between 160(v1 ₂) and 58(EV₀) is 102 which islarger than 8, thus 160(v1 ₂) is added to encoding pattern table 81 toupdate EV₁. For V1 ₃, difference between 160(v1 ₁) and 160(EV₁) is 0which is not larger than 8, thus 16(v1 ₃) is not added to encodingpattern table 81 either. For V₁₄, difference between 200(v1 ₄) and58(EV₀) is 142 and difference between 200(v1 ₄) and 160(EV₁) is 40,which are both larger than 8, thus 200(v1 ₄) is added to encodingpattern table 81 to update EV₂. After v1 ₀˜v1 ₁₅ are completelyconsidered, encoding values EV₀˜EV₄ in encoding pattern table 81 areupdated as 58, 160, 200 79 and 105, encoding values EV₅˜EV₇ are keptbeing null. FIG. 3B is the updated encoding pattern table 81.

After encoding pattern table 81 is initially updated, image processingdevice 500 receives next image data IMG comprising a plurality of pixelvalues p₀˜p_(n). First encoder 110 generates first data DAT₁ by encodingIMG according to discrete cosine transformation (DCT) method, which is apredetermined method in the embodiment. Simultaneously, second encoder120 generates second data DAT₂ by encoding IMG according to encodingpattern table 81. To generate the second data DAT₂, second encoder 120compares each pixel value with encoding values EV₀˜EV_(k) in encodingpattern table 81 to obtain the encoding values which have the leastdifference with the pixel values in the encoding pattern table togenerate second data DAT₂. Second data DAT₂ comprises a plurality ofbins b₀˜b_(n), the bins are equivalent to the corresponding encodingindexes, and each encoding indexes corresponds to a pixel value in imagedata IMG.

An exemplary embodiment of second encoder 120 encoding image data IMGaccording to encoding pattern table 81 is shown as follows. Encodingpattern table 81 may recode 8 encoding values EV₀˜EV₇. After initiallyupdating encoding pattern table 81, the values of EV₅˜EV₇ are null, forexample, and EV₀˜EV₄ corresponding to encoding indexes 0˜4 are 58, 160,200, 79 and 105 respectively as shown in FIG. 4A. Image data IMGcomprising 16 pixel values p₀˜p₁₅ is received by second encoder 120 asshown in FIG. 4B. Second encoder 120 compares pixel value 200(p₀) withthe encoding values in encoding pattern table 81. Encoding value200(EV₂) corresponding to encoding index 2 has the least difference withpixel value 200(p₀) in encoding pattern table 81. Thus second encoder120 generates bin b₀ of second data DAT₂ to represent pixel value200(p₀), wherein bin b₀ is equivalent to encoding index 2 and symbolizedby binary data 010. Similarly, second encoder 120 then compares pixelvalue 202(p₁) with the encoding values in encoding pattern table 81.Encoding value 200(EV₂) corresponding to encoding index 2 has the leastdifference with pixel value 202(p₁) in encoding pattern table 81, thusbin b₁ of second data DAT₂ corresponding to p₁ is symbolized by 010,too. Next, encoding value 58 corresponding to encoding index 0 has theleast difference with pixel value 58(p₃), thus bin b₃ of second dataDAT₂ corresponding to p₃ is equivalent to encoding index 0 andsymbolized by binary data 000. After finishing comparing all of thepixel values p₀˜p₁₅ with the encoding values in encoding pattern table81, bins b₀˜b_(n) corresponding to pixel values p₀˜p_(n) are obtainedand FIG. 4C is shown the second data DAT₂ comprising bins b₀˜b_(n).

After generating DAT₁ and DAT₂ by first encoder 110 and second encoder120 respectively, encoding switch 150 determines to output either firstdata DAT₁ or second data DAT₂ as an encoded result according tocharacteristics of first data DAT₁ and second data DAT₂. Thecharacteristics are data lengths and coding errors of first data DAT₁and second data DAT₂ in the embodiment. Encoding switch 150 determinesto output second data DAT₂ as the encoded result when sum of the datalength and the coding error of second data DAT₂ is less than sum of thedata length and the coding error of the first data DAT₁. Otherwise,encoding switch 150 determines to output first data DAT₁ as the encodedresult.

Data lengths of DAT₁ and DAT₂ are calculated by numbers of bits in DAT₁and DAT₂. For example, the data length of DAT₂ in FIG. 4C is 48. Tocalculate the coding error of DAT₁, encoding switch 150 first obtainsfirst decoding data DE₁, as shown in FIG. 4A, comprising first values v1₀˜v1 _(n) by decoding DAT₁ according to the DCT method. The coding errorof DAT₁ is calculated according to the difference between pixel valuesp₀˜p_(n) of IMG and first values v1 ₀˜v1 _(n) of decoding data DE₁.Similarly, the coding error of DAT₂ is calculated according to pixelvalues p₀˜p_(n) of IMG and bins b₀˜b_(n) which corresponding to encodingvalues of pixel values. In the embodiment, the coding error of DAT₁ iscalculated by summing up absolute differences between the pixel valuesand the first decoding data DE₁, wherein coding error of

${DAT}_{1} = {\sum\limits_{i = 0}^{n}{{{p_{i} - v_{i}}}.}}$

The coding error of DAT₂ is calculated by summing up absolutedifferences between pixel values p₀˜p_(n) and the encoding values ofpixel values, wherein coding error of

${DAT}_{2} = {\sum\limits_{i = 0}^{n}{{{p_{i} - {EV}_{b_{i}}}}.}}$

For example, referencing FIGS. 4B and 4C, encoding value 200(EV₂)corresponding to encoding index 2 is symbolized by bin b₀, thus theabsolute difference between pixel value 200(p₀) and bin b₀ is 0. FIG. 4Dis the absolute differences between pixel values p₀˜p₁₅ and binsb₀˜b_(n). The sum of the absolute differences of DAT₂ is 34. In theembodiment, the coding error of DAT₂ is 34 accordingly. Thus, the sum ofthe data length and the coding error of DAT₂ are 82. Encoding switch 150outputs DAT₂ as the encoded result when 82, the sum of the data lengthand the coding error of DAT₂, is less than the sum of the data lengthand the coding error of DAT₁.

When encoding switch 150 determines to output first data DAT₁ as theencoded result, encoding switch 150 uses first values v1 ₀˜v1 _(n) inDE₁ to update the encoding values EV₀˜EV_(k) in encoding pattern table81. Encoding values EV₀˜EV_(k) are updated by adding the first values,whose differences from encoding values EV₀˜EV_(k) in encoding patterntable 81 are larger than 8, which is a predetermined threshold, to theencoding pattern table. When the number of the encoding values reachesthe predetermined value, i.e. there is no null in EV₀˜EV_(k), theencoding value which is first added to encoding pattern table 81 isreplaced with the adding first value. For example, the encoding patterntable 81 which is going to be updated is shown as FIG. 4B. When one ofthe first values is 205, 205 is not added into the encoding patterntable because encoding value 200 exists in the table, in which thedifference between 205 and 200 is not larger than 8. On the other hand,when one of the first values is 50, 50 is added into the encodingpattern table because differences between 50 and each encoding valuesare larger than 8. After determining to output DAT₁ or DAT₂, encodingswitch 150 generates a mark value M, indicating the encoded result isfirst data DAT₁ encoded according to the DCT method by first encoder 110or is second data DAT₂ encoded according to encoding pattern table 81 bysecond encoder 120.

Decoding switch 250 receives the encoded result, either first data DAT₁or second data DAT₂, and mark value M outputted from encoding switch150. Decoding switch 250 determines the encoded result is first dataDAT₁ encoded according to the DCT method by first encoder 110 or issecond data DAT₂ encoded according to encoding pattern table 81 bysecond encoder 120 according to the mark value M.

When the encoded result is first data DAT₁ encoded according to the DCTmethod by first encoder 110, first decoder 210 generates first decodingdata DE₁ comprising first values v1 ₀˜v1 _(n) by decoding the encodeddata, DAT₁ according to the DCT method, the predetermined method, anduses v1 ₀˜v1 _(n) to update DV₀˜DV_(k) in decoding pattern table 82. Theupdating method for decoding pattern table 82 is the same as encodingpattern table 81. Decoding values DV₀˜DV_(k) are updated by adding firstvalues v₀˜v_(n), whose differences from decoding values DV₀˜DV_(k) indecoding pattern table 82 are larger than 8, the predeterminedthreshold, to decoding pattern table 82. As encoding pattern table 81,when the number of decoding values reaches the predetermined value, i.e.there is no null in DV₀˜DV_(k), the decoding value which is first addedto decoding pattern table 82 is replaced with the adding first value.

Contrarily, when the encoded result is second data DAT₂ encodedaccording to encoding pattern table 81 by second encoder 120, seconddecoder 220 generates second decoding data DE₂ by decoding the encodeddata, DAT₂, according to decoding pattern table 82. For generatingsecond decoding data DE₂, second decoder 220 compares each bin in DAT₂with the decoding indexes 0˜k in decoding pattern table 82 to obtain thedecoding values corresponding to the decoding indexes which areequivalent to bins b₀˜b_(n) to generate DE₂. DE₂ comprises a pluralityof second values v2 ₀˜v2 _(n), v2 ₀˜v2 _(n) are equivalent to thecorresponding decoding values, and each second value corresponds to abin in DAT₂.

An exemplary embodiment of second decoder 220 decoding second data DAT₂according to decoding pattern table 82 is shown as follows. Decodingpattern table 82 shown in FIG. 5A may recode 8 encoding values DV₀˜DV₇.At the beginning, the values of DV₅˜DV₇ are null and DV₀˜DV₄corresponding to decoding indexes 0˜4 in decoding pattern table 81 are58, 160, 200, 79 and 105 respectively. Referring to FIG. 5B, second dataDAT₂ comprising 16 bins b₀˜b₁₅ is received by second decoder 220 fromdecoding switch 250. Second decoder 220 compares b₀ with decodingindexes in decoding pattern table 82. The decoding value corresponds toencoding index 2 which is equivalent to b₀ is 200(DV₂), thus secondvalue v2 ₀ corresponding to b₀ is 200. Similarly, second decoder 220then compares b₁ with each encoding index in decoding pattern table 82.The encoding value corresponding to decoding index 2 which is equivalentto b₁ is 200(DV₂), second value v2 ₁ corresponding to b₁ is 200, too.Next, the decoding value corresponding to decoding index 0 which isequivalent to b₂ is 58(DV₀), thus second value v2 ₂ corresponding to b₂is 58. After finishing comparing all of the bins b₀˜b₁₅ with thedecoding values in decoding pattern table 82, the second values v2 ₀˜v2_(n) corresponding to the pixel values b₀˜b_(n) are the second decodingdata DE₂ as shown in FIG. 5C.

FIG. 6 is a flowchart of the image processing method disclosed in anembodiment. Image data IMG comprising a plurality of pixel valuesp₀˜p_(n) is received by an image processing device (S1) An encodingpattern table comprising a plurality of encoding indexes 0˜k andencoding values EV₀˜EV_(k) stored in a first storage element isprovided. (S2) Each encoding value corresponds to one of the encodingindexes in the encoding pattern table. First data DAT₁ is generated byencoding image data IMG according to the DCT method, the predeterminedmethod. (S3) Second data DAT₂ is generated by encoding image data IMGaccording to the encoding pattern table. (S4) Either first data DAT₁ orsecond data DAT₂ is determined to be outputted as an encoded resultaccording to characteristics of DAT₁ and DAT₂ by an encoding switch.(S5) A mark value M indicating the encoded result is the first data DAT₁encoded according to the DCT method or is the second data DAT₂ encodedaccording to the encoding pattern table is outputted by the encoderswitch. When the encoded result is the first data encoded according tothe DCT method, first decoding data DE₁ comprising first values v1 ₀˜v1_(n) by decoding first data DAT₁ according to the DCT method and firstvalues v1 ₀˜v1 _(n) is used to update encoding values EV₀˜EV_(k) in theencoding pattern table, DAT₁ and mark value M indicating the encodedresult is the first encoded data are outputted by the encoding switch.(S6) When the encoded result is the second data encoded according to theencoding pattern table, DAT₂ and mark value M indicating the encodedresult is the second data are outputted by the encoder switch (S7).

In S4, second data DAT₂ comprises a plurality of bins b₀˜b_(n). Eachpixel value p₀˜p_(n) is compared with encoding values EV₀˜EV_(k) in theencoding pattern table to generate second data DAT₂. Bins in DAT₂ areequivalent to the encoding indexes corresponding to the encoding valueswhich have the least difference with the pixel values in the encodingpattern table.

In S5, the characteristic are data lengths and coding errors of DAT₁ andDAT₂ in the embodiment. Second data DAT₂ is determined to be outputtedwhen sum of the data length and the coding error of DAT₂ is less thansum of the data length and the coding error of DAT₁. To calculate thecoding error of DAT₁, encoding switch 150 first obtains first decodingdata DE₁ comprising first values v1 ₀˜v1 _(n) by decoding DAT₁ accordingto the DCT method. Each first value in DE₁ corresponds to a pixel valuein IMG. The coding error of DAT₁ is calculated according to pixel valuesp₀˜p_(n) and first values v1 ₀˜v1 _(n) in DE₁, the coding error of DAT₂is calculated according to pixel values p₀˜p_(n) and bins b₀˜b_(n) inDAT₂. In the embodiment, the coding error of DAT₁ is calculated bysumming up absolute differences between p₀˜p_(n) and v1 ₀˜v1 _(n) inDE₁, and the coding error of DAT₂ is calculated by summing up absolutedifferences between p₀˜p_(n) and the encoding values corresponding tothe encoding indexes which are equivalent to b₀˜b_(n) in DAT₂.

In S6, encoding values EV₀˜EV_(k) are updated by adding the firstvalues, whose differences from the encoding values in the encodingpattern table are larger than a predetermined threshold, to the encodingpattern table. Number of the encoding values in the encoding patterntable is under a predetermined value, the encoding value which is firstadded to the encoding pattern table are replaced with the adding firstvalue when the number of the encoding values reaches the predeterminedvalue.

The encoded result and mark value M outputted from the encoding switchare received by a decoding switch. (S8) A decoding pattern tablecomprising a plurality of decoding indexes 0˜k and decoding valuesDV₀˜DV_(k) stored in a second storage element is provided. (S9) Eachdecoding value corresponds to one of the decoding indexes in thedecoding pattern table. The encoded result is the first data DAT₁encoded according to the DCT method or is the second data DAT₂ encodedaccording to the encoding pattern table is determined according to markvalue M. (S10) First decoding data DE₁ comprising first values v1 ₀˜v1_(n) is generated by decoding DAT₁ according to the DCT method and firstvalues v1 ₀˜v1 _(n) are used to update decoding values DV₀˜DV_(k) in thedecoding pattern table when the encoded result is the first data DAT₁encoded according to the DCT method. (S11) Second decoding data DE₂ isgenerated by decoding DAT₂ according to the decoding pattern table whenthe encoded result is the second data DAT₂ encoded according to theencoding pattern table. (S12)

In S11, decoding values DV₀˜DV_(k) are updated by adding the firstvalues, whose differences from the decoding values in the decodingpattern table are larger than a predetermined threshold, to the decodingpattern table. Number of the decoding values in the decoding patterntable is under a predetermined value, the decoding value which is firstadded to the decoding pattern table is replaced with the adding firstvalue when the number of the decoding values reaches the predeterminedvalue.

In S12, second data DAT₂ comprises a plurality of bins b₀˜b_(n) andsecond decoding data DE₂ comprises a plurality of second values v₀˜v₀.Each bin is compared with the decoding indexes in the decoding patterntable to generate second decoding data DE₂. Second values v2 ₀˜v2 _(n)in DE₂ are equivalent to the decoding values corresponding to thedecoding indexes which are equivalent to bins b₀˜b_(n) in DAT₂.

Based on the pattern table in the embodiment, the images which haverepeated pixel values may be encoded by the indexes with a shorter datalength than encoded by the DCT method. For the images without repeatedpixel values, the values in the pattern table are not similar to thepixel values and the image cannot be correctly encoded by the patterntable, the images encoded by the DCT method in the embodiment.Accordingly, the disclosed image processing device and method mayefficiently increase the compression rate especially for the syntheticimages which usually have repeated pixel values.

Systems and methods, or certain aspects or portions thereof, may takethe form of a program code (i.e., instructions) embodied in a tangiblemedia, such as floppy diskettes, CD-ROMS, hard drives, or any othermachine-readable storage medium, wherein, when the program code isloaded into and executed by a machine, such as a computer system and thelike, the machine becomes an apparatus for practicing the invention. Thedisclosed methods and apparatuses may also be embodied in the form of aprogram code transmitted over some transmission medium, such aselectrical wiring or cabling, through fiber optics, or via any otherform of transmission, wherein, when the program code is received andloaded into and executed by a machine, such as a computer or an opticalstorage device, the machine becomes an apparatus for practicing theinvention. When implemented on a general-purpose processor, the programcode combines with the processor to provide a unique apparatus thatoperates analogously to specific logic circuits.

While the invention has been described by way of example and in terms ofthe preferred embodiments, it is to be understood that the invention isnot limited to the disclosed embodiments. To the contrary, it isintended to cover various modifications and similar arrangements (aswould be apparent to those skilled in the art). Therefore, the scope ofthe appended claims should be accorded the broadest interpretation so asto encompass all such modifications and similar arrangements.

1. An image processing device, receiving image data comprising aplurality of pixel values, comprising: a first encoder configured togenerate first data by encoding the image data according to apredetermined method; a second encoder configured to generate seconddata by encoding the image data according to an encoding pattern table,wherein the encoding pattern table is set up in accordance with thefirst data; and an encoding switch configured to determine to outputeither the first data or the second data as an encoded result andgenerate a mark value for indicating the encoded result.
 2. The imageprocessing device claimed in claim 1, wherein the encoding pattern tablecomprises a plurality of encoding indexes and encoding values, eachencoding value corresponds to one of the encoding indexes.
 3. The imageprocessing device claimed in claim 2, wherein the encoding switchfurther updates the encoding values in the pattern table by firstdecoding data, wherein the first decoding data is obtained by decodingthe first data.
 4. The image processing device claimed in claim 3,wherein the encoded result is determined according to characteristics ofthe first data and the second data.
 5. The image processing deviceclaimed in claim 2, wherein the second data comprises a plurality ofbins, the second encoder further compares each pixel value with theencoding values in the encoding pattern table to generate the seconddata comprising the bins in which the bins are equivalent to theencoding indexes corresponding to the encoding values which have theleast difference with the pixel values in the encoding pattern table. 6.The image processing device claimed in claim 3, wherein the firstdecoding data comprises a plurality of first values, the encoding valuesare updated by adding the first values, whose differences from theencoding values in the encoding pattern table are larger than apredetermined threshold, to the encoding pattern table.
 7. The imageprocessing device claimed in claim 4, wherein number of the encodingvalues in the encoding pattern table is under a predetermined value, theencoding value which is first added to the encoding pattern table isreplaced with the adding first value when the number of the encodingvalues reaches the predetermined value.
 8. The image processing deviceas claimed in claim 3, wherein the characteristics are data lengths andcoding errors of the first data and the second data, the encoding switchdetermines to output the second data when the sum of the data length andthe coding error of the second data is less than the sum of the datalength and the coding error of the first data.
 9. The image processingdevice as claimed in claim 8, wherein the coding error of the first datais calculated according to the pixel values and the first values in thefirst decoding data, and the coding error of the second data iscalculated according to the pixel values and the bins in the seconddata.
 10. The image processing device as claimed in claim 1, furthercomprising: a second storage element configured to store a decodingpattern table comprising a plurality of decoding indexes and decodingvalues, with each decoding value corresponding to one of the decodingindexes; a decoding switch configured to receive the encoded result andthe mark value outputted from the encoding switch, determine the encodedresult is the first data encoded according to the predetermined methodor is the second data encoded according to the encoding pattern tableaccording to the mark value; a first decoder configured to generate thefirst decoding data comprising the first values by decoding the firstdata according to the predetermined method and use the first values toupdate the decoding values in the decoding pattern table when theencoded result is the first data encoded according to the predeterminedmethod; and a second decoder configured to generate the second decodingdata by decoding the second data according to the decoding pattern tablewhen the encoded result is the second data encoded according to theencoding pattern table.
 11. An image processing method, receiving imagedata comprising a plurality of pixel values by an image processing unit,comprising: providing an encoding pattern table comprising a pluralityof encoding indexes and encoding values stored in a first storageelement, each encoding value corresponding to one of the encodingindexes; generating first data by encoding the image data according to apredetermined method; generating second data by encoding the image dataaccording to the encoding pattern table; determining to output eitherthe first data or the second data as an encoded result according tocharacteristics of the first data and the second data by an encodingswitch; obtaining first decoding data comprising first values bydecoding the first data according to the predetermined method and usingthe first values to update the encoding values in the encoding patterntable when the encoded result is the first data encoded according to thepredetermined method; and generating a mark value indicating the encodedresult is the first data encoded according to the predetermined methodor is the second data encoded according to the encoding pattern table.12. The image processing method as claimed in claim 11, wherein thesecond data comprises a plurality of bins, further comprising comparingeach pixel value with the encoding values in the encoding pattern tableto generate the second data comprising the bins in which the bins areequivalent to the encoding indexes corresponding to the encoding valueswhich have the least difference with the pixel values in the encodingpattern table.
 13. The image processing method as claimed in claim 11,wherein the encoding values are updated by adding the first values,whose differences from the encoding values in the encoding pattern tableare larger than a predetermined threshold, to the encoding patterntable.
 14. The image processing method as claimed in claim 13, whereinnumber of the encoding values in the encoding pattern table is under apredetermined value, the encoding value which is first added to theencoding pattern table are replaced with the adding first value when thenumber of the encoding values reaches the predetermined value.
 15. Theimage processing method as claimed in claim 11, wherein thecharacteristics are data lengths and coding errors of the first data andthe second data, the second data is determined to be outputted when sumof the data length and the coding error of the second data is less thansum of the data length and the coding error of the first data.
 16. Theimage processing method as claimed in claim 15, wherein the coding errorof the first data is calculated according to the pixel values and thefirst values in the first decoding data, the coding error of the seconddata is calculated according to the pixel values and the bins in thesecond data.
 17. The image processing method as claimed in claim 11,further comprising: receiving the encoded result and the mark value fromthe encoding switch by a decoding switch; providing a decoding patterntable comprising a plurality of decoding indexes and decoding valuesstored in a second storage element, each decoding value corresponding toone of the decoding indexes; determining the encoded result is the firstdata encoded according the predetermined method or is the second dataencoded according to the encoding pattern table according to the markvalue; generating the first decoding data comprising the first values bydecoding the first data according to the predetermined method and usingthe first values to update the decoding values in the decoding patterntable when the encoded result is the first data encoded according thepredetermined method; and generating second decoding data by decodingthe second data according to the decoding pattern table when the encodedresult is the second data encoded according to the encoding patterntable.
 18. The image processing method as claimed in claim 17, whereinthe second data comprises a plurality of bins and the second decodingdata comprises a plurality of second values, further comprisingcomparing each bin with the decoding indexes in the decoding patterntable to generate the second decoding data comprising the second valuesin which the second values are equivalent to the decoding valuescorresponding to the decoding indexes which are equivalent to the binsin the second data.
 19. The image processing method as claimed in claim17, wherein the decoding values are updated by adding the first values,whose differences from the decoding values in the decoding pattern tableare larger than a predetermined threshold, to the decoding patterntable.
 20. The image processing method as claimed in claim 11, whereinthe predetermined method is discrete cosine transformation (DCT).